package acm.蓝桥5;

import java.util.Scanner;

public class Golomb自描述序列 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(fun(n));
    }

    public static int fun(int n) {
        if (n <= 3) {
            return n == 1 ? 1 : 2;
        }
        int[] gn = new int[n + 1];
        int[] queue = new int[n + 1];
        int h = 0, t = 0;
        gn[1] = 1;
        gn[2] = 2;
        queue[t++] = 2;
        for (int i = 3; i <= n; i++) {
            int head = queue[h++];
            if (i + t - h + head >= n) {    //gn的总数+当前队列中的数+要添加的数>=n
                return i;
            }
            for (int j = 0; j < head; j++) {
                queue[t++] = i;
            }
            gn[i] = head;
        }
        return gn[n];
    }
}
